#!/bin/bash
. ./config.cfg
TOKEN=`./get_token.sh`
TSUNG_SLAVE_MARATHON_ID=`./get_app_name.sh`

curl -X POST $BASE_URL/api/v3/clusters/$SRY_CLUSTERID/apps \
    -H Authorization:$TOKEN \
    -H Content-Type:application/json -d '{
       "name": "tsung_master",
       "cpus": 1,
       "mem": 1024,
       "instances": 1,
       "volumes": [],
       "imageName": "'$TSUNG_IMAGE_URI'",
       "imageVersion": "'$TSUNG_IMAGE_VERSION'",
       "forceImage": false,
       "constraints": [["ip", "LIKE", "'$TSUNG_MASTER_IP'" ], ["ip", "UNIQUE"]],
       "network": "HOST",
       "envs": [
        {
            "key": "TSUNG_SLAVE_MARATHON_ID",
            "value": "'$TSUNG_SLAVE_MARATHON_ID'"
        },
        {
            "key": "MARATHON_URL",
            "value": "'$MARATHON_URL'"
        },
        {
            "key": "TSUNG_ROLE",
            "value": "MASTER"
        },
        {
            "key": "CONFIG_SERVER",
            "value": "'$CONFIG_SERVER'"
        },
        {
            "key": "SERVICE",
            "value": "tsung"
        },
        {
            "key": "NOHOSTNAME",
            "value": "true"
        }
            ],

      "portMappings":[],
      "logPaths": []
    }'
